import http from "./http";
import qs from "qs";
import axios from 'axios';

//保存
/**
 * 
 * @param {robotNoticeDTO} params
 * {
  "agent": 0,
  "content": "string",
  "createdTime": "2021-12-17T01:59:30.277Z",
  "id": 0,
  "room": 0,
  "status": 0,
  "updatedTime": "2021-12-17T01:59:30.277Z",
  "user": 0
  } 
 * @returns 
 */
export const noticeSave = (params) => {
  return http.post("/notice/save", params)
}
//修改
/**
 * 
 * @param {robotNoticeDTO } params 
 * {
  "agent": 0,
  "content": "string",
  "createdTime": "2021-12-17T02:01:16.099Z",
  "id": 0,
  "room": 0,
  "status": 0,
  "updatedTime": "2021-12-17T02:01:16.099Z",
  "user": 0
  }
 * @returns 
 */
export const noticeUpdate = (params) => {
  return http.post("/notice/update", params)
}
//修改状态 1启用 0停用
// id
// status
export const updateStatus = (params) => {
  return http.post("/notice/updateStatus", qs.stringify(params))
}
// 分页获取公告
// pageSize
// currentPage
export const noticePage = (params, that) => {
  return http.get("/notice/getPage", params, {
    cancelToken: new axios.CancelToken(function executor(c) {
      // 设置 cancel token
      that.source = c;
    })
  })
}
// 删除公告
export const deleteById = (params) => {
  return http.get("/notice/deleteById", params)
}

//获取typesList

export const getTypeList = (params) => {
  return http.get("/notice/getTypeList")
}
// eslint-disable-next-line import/no-anonymous-default-export
export default {
  noticeSave,
  noticeUpdate,
  updateStatus,
  noticePage,
  deleteById,
  getTypeList
}